home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #002 (19xx)(Amiga User Group Deutschland e.V.).zip / Franz PD Disk #002 (19xx)(Amiga User Group Deutschland e.V.).adf / Trails / TrailsMenu.mod < prev    next >
Text File  |  1986-10-22  |  8KB  |  242 lines

  1. (*
  2.     This module initializes the menus for the Trails
  3.     demo.
  4.  
  5.     Created: 5/22/86 by Richard Bielak
  6.     
  7.     Modified:
  8.  
  9.  
  10.     Copyright (c) 1986 by Richard Bielak.
  11.     
  12.     This is a Public Domain piece of code, please don't
  13.     try to sell it! Also, please leave my name in.
  14.     Thanks.....Richie.
  15.  
  16. *)
  17. IMPLEMENTATION MODULE TrailsMenu;
  18.  
  19. FROM SYSTEM    IMPORT ADDRESS, ADR, BYTE;
  20. FROM Intuition     IMPORT WindowPtr, Menu, MenuPtr, IntuitionText,
  21.                 IntuitionTextPtr, MenuItem, MenuItemPtr,
  22.                MenuFlags, MenuFlagsSet, ItemFlags, ItemFlagsSet;
  23. FROM Menus    IMPORT SetMenuStrip, ClearMenuStrip, HighComp;
  24. FROM GraphicsLibrary IMPORT Jam2, Jam1, DrawingModeSet;
  25.  
  26. CONST
  27.   CheckWidth = 19; (* From Intuition.h *)
  28.  
  29. VAR
  30.   NULL : ADDRESS;
  31.   MenuStrip : MenuPtr;
  32.  
  33.   (*  ACTIONS   SYMETRY   SIZE  SQUARE*)
  34.   Menus     : ARRAY [0..3] OF Menu;
  35.  
  36.   (* HideStrip, ShowStrip, About, Clear, Quit *)
  37.   ActionItems : ARRAY [0..4] OF MenuItem;
  38.   ActionText  : ARRAY [0..4] OF IntuitionText;
  39.  
  40.   (* 1 Fold, 2 Fold, 4 Fold *)
  41.   SymetryItems : ARRAY [0..2] OF MenuItem;
  42.   SymetryText  : ARRAY [0..2] OF IntuitionText;
  43.  
  44.   (* 16, 32, 64, 128, infinity *)
  45.   SizeItems : ARRAY [0..4] OF MenuItem;
  46.   SizeText  : ARRAY [0..4] OF IntuitionText;
  47.  
  48.   (* 2 by 2, 4 by 4, 8 by 8, 16 by 16, 32 by 32 *)
  49.   SquareSizeItems : ARRAY [0..4] OF MenuItem;
  50.   SquareSizeText  : ARRAY [0..4] OF IntuitionText;
  51.   
  52. (* ++++++++++++++++++++++++++++++++ *)
  53. (* Connect a menu strip to a window *)
  54. PROCEDURE ConnectMenu (wp : WindowPtr);
  55.   BEGIN
  56.     SetMenuStrip (wp^, MenuStrip^);
  57.   END ConnectMenu;
  58.  
  59. (* +++++++++++++++++++++++++++++++++++++ *)
  60. (* Disconnect a menu strip from a window *)
  61. PROCEDURE DisconnectMenu (wp : WindowPtr);
  62.   BEGIN
  63.     ClearMenuStrip (wp^)
  64.   END DisconnectMenu;
  65.  
  66. (* ++++++++++++++++++++++++++++++++ *)
  67. (* Initialize a menu record.        *)
  68. PROCEDURE InitMenuRec (VAR m : Menu; L, T, W, H : INTEGER;
  69.                        VAR text : ARRAY OF CHAR) 
  70.                : MenuPtr;
  71.   BEGIN
  72.     WITH m DO
  73.       NextMenu := NULL;
  74.       LeftEdge := L; TopEdge := T;
  75.       Width := W; Height := H;
  76.       Flags := MenuFlagsSet {MenuEnabled};
  77.       MenuName := ADR (text);
  78.       FirstItem := NULL
  79.     END;
  80.     RETURN ADR (m)
  81.   END InitMenuRec;
  82.  
  83. (* ++++++++++++++++++++++++++++++++ *)
  84. (* Initialize an item record.       *)
  85. PROCEDURE InitItemRec (VAR mi : MenuItem;
  86.                        L, T, W, H : INTEGER;
  87.                ItemFillPtr : ADDRESS) 
  88.                : MenuItemPtr;
  89.   BEGIN
  90.     WITH mi DO
  91.       NextItem := NULL;
  92.       LeftEdge := L; TopEdge := T;
  93.       Width := W; Height := H;
  94.       Flags := ItemFlagsSet {ItemText, ItemEnabled} + HighComp;
  95.       MutualExclude := 0;
  96.       ItemFill := ItemFillPtr;
  97.       SelectFill := NULL; Command := BYTE (0);
  98.       SubItem := NULL; NextSelect := 0;
  99.     END;
  100.     RETURN ADR (mi)
  101.   END InitItemRec;
  102.  
  103. (* ++++++++++++++++++++++++++++++++ *)
  104. (* Initialize menu text record.     *)
  105. PROCEDURE InitTextRec (VAR it : IntuitionText;
  106.                        L, T : INTEGER;
  107.                VAR text : ARRAY OF CHAR) 
  108.                        : IntuitionTextPtr;
  109.   BEGIN
  110.     WITH it DO
  111.       FrontPen := BYTE(0); BackPen := BYTE(1);
  112.       LeftEdge := L; TopEdge := T;
  113.       DrawMode := BYTE (DrawingModeSet {Jam2});
  114.       ITextFont := NULL;
  115.       IText := ADR (text);
  116.       NextText := NULL
  117.     END;
  118.     RETURN ADR (it);
  119.   END InitTextRec;
  120.  
  121.  
  122. VAR
  123.   temp : ADDRESS;
  124.   i    : CARDINAL;
  125.  
  126. BEGIN
  127.   NULL := 0;
  128.   MenuStrip := NULL;
  129.   (* Now init menu records *)
  130.   MenuStrip :=
  131.    InitMenuRec (Menus[0], 10, 0, 112, 0, "Actions");
  132.   Menus[0].NextMenu := 
  133.     InitMenuRec (Menus[1], 10+112, 0, 80, 0, "Symetry");
  134.   Menus[1].NextMenu := 
  135.     InitMenuRec (Menus[2], 10+112+80, 0, 84, 0, "Length");
  136.   Menus[2].NextMenu := 
  137.     InitMenuRec (Menus[3], 10+112+80+84, 0, 100, 0, "Size");
  138.  
  139.   (* Define action items *)
  140.   temp := InitTextRec (ActionText[0], 0, 0, "Hide Title Bar");
  141.   Menus[0].FirstItem := 
  142.     InitItemRec (ActionItems[0], 0, 0, 112, 9, temp);
  143.   temp := InitTextRec (ActionText[1], 0, 0, "Show Title Bar");
  144.   ActionItems[0].NextItem :=
  145.     InitItemRec (ActionItems[1], 0, 10, 112, 9, temp);
  146.   temp := InitTextRec (ActionText[2], 0, 0, "About Trails");
  147.   ActionItems[1].NextItem :=
  148.     InitItemRec (ActionItems[2], 0, 20, 112, 9, temp);
  149.   temp := InitTextRec (ActionText[3], 0, 0, "Clear");
  150.   ActionItems[2].NextItem :=
  151.     InitItemRec (ActionItems[3], 0, 30, 112, 9, temp);
  152.   temp := InitTextRec (ActionText[4], 0, 0, "Quit");
  153.   ActionItems[3].NextItem :=
  154.     InitItemRec (ActionItems[4], 0, 40, 112, 9, temp);
  155.  
  156.   (* Define Symetry Items *)
  157.   temp := InitTextRec (SymetryText[0], 0+CheckWidth, 0, "1 Fold");
  158.   Menus[1].FirstItem := 
  159.     InitItemRec (SymetryItems[0], 0, 0, 80, 9, temp);
  160.   INCL (SymetryItems[0].Flags,CheckIt);
  161.   SymetryItems[0].MutualExclude := 0FEH;
  162.  
  163.   temp := InitTextRec (SymetryText[1], 0+CheckWidth, 0, "2 Fold");
  164.   SymetryItems[0].NextItem := 
  165.     InitItemRec (SymetryItems[1], 0, 10, 80, 9, temp);
  166.   INCL (SymetryItems[1].Flags,CheckIt);
  167.   INCL (SymetryItems[1].Flags,Checked);
  168.   SymetryItems[1].MutualExclude := 0FDH;
  169.  
  170.   temp := InitTextRec (SymetryText[2], 0+CheckWidth, 0, "4 Fold");
  171.   SymetryItems[1].NextItem := 
  172.     InitItemRec (SymetryItems[2], 0, 20, 80, 9, temp);
  173.   INCL (SymetryItems[2].Flags,CheckIt);
  174.   SymetryItems[2].MutualExclude := 0FBH;
  175.  
  176.   (* Define Size items *)
  177.   temp := InitTextRec (SizeText[0], 0+CheckWidth, 0, "16");
  178.   Menus[2].FirstItem := 
  179.     InitItemRec (SizeItems[0], 0, 0, 84, 9, temp);
  180.   INCL (SizeItems[0].Flags,CheckIt);
  181.   SizeItems[0].MutualExclude := 0FEH;
  182.   
  183.   temp := InitTextRec (SizeText[1], 0+CheckWidth, 0, "32");
  184.   SizeItems[0].NextItem := 
  185.     InitItemRec (SizeItems[1], 0, 10, 84, 9, temp);
  186.   INCL (SizeItems[1].Flags,CheckIt);
  187.   SizeItems[1].MutualExclude := 0FDH;
  188.  
  189.   temp := InitTextRec (SizeText[2], 0+CheckWidth, 0, "64");
  190.   SizeItems[1].NextItem := 
  191.     InitItemRec (SizeItems[2], 0, 20, 84, 9, temp);
  192.   INCL (SizeItems[2].Flags,CheckIt);
  193.   INCL (SizeItems[2].Flags,Checked);
  194.   SizeItems[2].MutualExclude := 0FBH;
  195.  
  196.   temp := InitTextRec (SizeText[3], 0+CheckWidth, 0, "128");
  197.   SizeItems[2].NextItem := 
  198.     InitItemRec (SizeItems[3], 0, 30, 84, 9, temp);
  199.   INCL (SizeItems[3].Flags,CheckIt);
  200.   SizeItems[3].MutualExclude := 0F7H;
  201.  
  202.   temp := InitTextRec (SizeText[4], 0+CheckWidth, 0, "Infinite");
  203.   SizeItems[3].NextItem := 
  204.     InitItemRec (SizeItems[4], 0, 40, 84, 9, temp);
  205.   INCL (SizeItems[4].Flags,CheckIt);
  206.   SizeItems[4].MutualExclude := 0EFH;
  207.  
  208.   (* Size Square items *)
  209.   temp := InitTextRec (SquareSizeText[0], 0+CheckWidth, 0, "2 by 2");
  210.   Menus[3].FirstItem := 
  211.     InitItemRec (SquareSizeItems[0], 0, 0, 100, 9, temp);
  212.   INCL (SquareSizeItems[0].Flags,CheckIt);
  213.   SquareSizeItems[0].MutualExclude := 0FEH;
  214.  
  215.   temp := InitTextRec (SquareSizeText[1], 0+CheckWidth, 0, "4 by 4");
  216.   SquareSizeItems[0].NextItem := 
  217.     InitItemRec (SquareSizeItems[1], 0, 10, 100, 9, temp);
  218.   INCL (SquareSizeItems[1].Flags,CheckIt);
  219.   INCL (SquareSizeItems[1].Flags,Checked);
  220.   SquareSizeItems[1].MutualExclude := 0FDH;
  221.  
  222.   temp := InitTextRec (SquareSizeText[2], 0+CheckWidth, 0, "8 by 8");
  223.   SquareSizeItems[1].NextItem := 
  224.     InitItemRec (SquareSizeItems[2], 0, 20, 100, 9, temp);
  225.   INCL (SquareSizeItems[2].Flags,CheckIt);
  226.   SquareSizeItems[2].MutualExclude := 0FBH;
  227.  
  228.   temp := InitTextRec (SquareSizeText[3], 0+CheckWidth, 0, "16 by 16");
  229.   SquareSizeItems[2].NextItem := 
  230.     InitItemRec (SquareSizeItems[3], 0, 30, 100, 9, temp);
  231.   INCL (SquareSizeItems[3].Flags,CheckIt);
  232.   SquareSizeItems[3].MutualExclude := 0F7H;
  233.  
  234.   temp := InitTextRec (SquareSizeText[4], 0+CheckWidth, 0, "32 by 32");
  235.   SquareSizeItems[3].NextItem := 
  236.     InitItemRec (SquareSizeItems[4], 0, 40, 100, 9, temp);
  237.   INCL (SquareSizeItems[4].Flags,CheckIt);
  238.   SquareSizeItems[4].MutualExclude := 0EFH;
  239.  
  240. END TrailsMenu.
  241.  
  242.